Java Developers Kit
class Parent { protected int x; }and
class Child extends Parent { ..... }The class Child can only access "x" on objects that are of type Child or that are a subtype of Child. If equal() is defined as a method of Child, then the following two uses of "x" are both legal
boolean equal(Child other) { return x == other.x; }because the left-most "x" is implicitly "this.x", so both "this" and "other" are of type Child.
Now suppose that class Child is a child of Parent and has a subclass SubChild. If Child attempts to define isEqual() as
static boolean isEqual(Parent one, SubChild two) { return one.x == two.x /* "one.x" illegal */ }the use to "two.x" is legal but "one.x" is illegal.
"static" protected variables and methods are accessible from any child class since there is no "object" through which to access them. "super.protectedMethod(...)" is always legal.
Note that "protected" still allows other classes in the same package to access protected variables or methods. To allow access only to those classes that satisfy the above rules, you must use "private protected".
protected void finalize() throws Throwable { }This means that:
protected native Object clone() throws CloneNotSupportedException;
If the class of an object has not been declared to implement the interface Cloneable, then a call to clone() on that object will fail and give the error CloneNotSupportedException. Remember, you can only call clone() on an object of the current class's type, or one of its subtypes.
If a class wishes to allow others to make copies, it should do the following:
class FOO ...... implements Cloneable { ........ public clone() { try { Object result = super.clone() ... other class dependent copying ... return result; } catch (CloneNotSupportedException e) { throw appropriate error } }If FOO extends Object, then the appropriate error should indicate that you've gotten an internal error!
If a component's handleEvent() method returns false, the event keeps traveling up the containment hierarchy. If none of the component's parents return true from their handleEvent() methods, then the event is sent to the peer which will consume the event. Unfortunately, for 1.0 Beta 2 (and fcs) the only events that will be able to be filtered by an application are keyboard events. Future versions of the JDK will allow all events to be filtered by the awt program.
Note that if an applet's textfields don't seem to be getting any keyboard input, it's probably because the applet is (incorrectly) returning "true" from its handleEvent() method. This causes the event to not be sent to the actual textfield.
C:\java\classes;C:\java\classes.zipon Windows NT and Windows 95, or
java/classes:java/classes.zipon Solaris.
Both the runtime class loader and the java compiler have been modified to load classes from zip files or directories chosen in the order specified in the class path. For example, if on Solaris the class 'java.io.File' is loaded with the above class path then the interpreter will first look for the file java/classes/java/io/File.class then for a zip member named 'java/io/File' in java/classes.zip.
On the PC, the java sources are now shipped in a single zip file in order to conserve space. You can create zip files containing your own classes for standalone applications using any of the freely available zip file archivers. The only current restriction is that the zip file members must not be compressed. You will probably also want to use a version of zip that understands long file names.
Java Developers Kit